package com.zx.Dao;

import java.sql.*;

/**
 * com.zx.Dao
 * 26832
 * zx
 * &#064;description: jdbc
 * &#064;author: lxm
 * Jdbc
 * &#064;create: 2024-06-21 16:27
 **/

public class Jdbc {
    private  String url ="jdbc:mysql://localhost:3308/zx";
    private String user = "root";
    private String password="root";
    private String driver = "com.mysql.cj.jdbc.Driver";


    public Connection getCon(){
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        Connection con = null;
        try{
            con = DriverManager.getConnection(url,user,password);
        }catch (Exception e){
            e.printStackTrace();
        }
        return con;
    }


    public void Close(Connection con, Statement smt, ResultSet rs) throws SQLException {
        if (rs!=null){
            con.close();
        }
        if (smt!=null){
            smt.close();
        }
        if (rs!=null){
            rs.close();
        }
    }
}
